package com.xxxx.server.controller;


import com.xxxx.server.pojo.Department;
import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.service.IDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhoubin
 */
@Api("部门管理")
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

	@Autowired
	private IDepartmentService departmentService;


	@ApiOperation(value = "获取所有部门")
	@GetMapping("/")
	public List<Department> selectAllDepartment(){
		List<Department> deps = departmentService.selectDepartmentAll();
		return deps;
	}


	@ApiOperation(value = "添加部门")
	@PostMapping("/")
	public RespBean addDepartment(@RequestBody Department department){
		return departmentService.addDepartment(department);
	}

	@ApiOperation(value = "删除部门")
	@DeleteMapping("/{id}")
	public RespBean deleteDepartment(@PathVariable Integer id){
		return departmentService.deleteDepartment(id);
	}

}
